Skip to content

feat: Provision minimal TokenReview RBAC for OIDC auth and add SSL error logging in token parser#6240

Open
aniketpalu wants to merge 1 commit intofeast-dev:masterfrom
aniketpalu:oidc-rbac-ssl-logging
Open

feat: Provision minimal TokenReview RBAC for OIDC auth and add SSL error logging in token parser#6240
aniketpalu wants to merge 1 commit intofeast-dev:masterfrom
aniketpalu:oidc-rbac-ssl-logging

Conversation

@aniketpalu
Copy link
Copy Markdown
Contributor

@aniketpalu aniketpalu commented Apr 8, 2026

What this PR does / why we need it:

When `authz: oidc` is configured, the Feast server delegates Kubernetes service account (SA) tokens to a lightweight TokenReview for validation and namespace extraction. This requires the server SA to have `tokenreviews/create` permission. Previously, this RBAC was not provisioned automatically by the operator for OIDC deployments (only for `authz: kubernetes`), requiring manual ClusterRole creation.

Operator: OIDC TokenReview RBAC

The operator now provisions a dedicated feast-oidc-token-review ClusterRole and ClusterRoleBinding when authz: oidc is configured. The ClusterRole contains exactly one rule:

  • authentication.k8s.io/tokenreviews/create

This is the minimum permission needed for the SA token delegation path. No additional RBAC queries (rolebindings, clusterroles, namespaces) are granted, unlike the authz: kubernetes path which needs broader permissions for KubernetesTokenParser.

Cleanup is handled automatically when switching auth types:

  • OIDC to kubernetes: OIDC ClusterRole + ClusterRoleBinding deleted
  • OIDC to no_auth: OIDC ClusterRole + ClusterRoleBinding deleted
  • kubernetes/no_auth to OIDC: OIDC ClusterRole + ClusterRoleBinding created

SDK: SSL Error Logging

When verify_ssl: true is set but the OIDC provider uses self-signed certificates without a configured ca_cert_path, the server fails to reach the JWKS/discovery endpoints. Previously, this produced a generic "Invalid token" log with no indication of the root cause. The token parser now detects SSL errors in the exception chain and logs a clear, actionable message:

OIDC provider SSL certificate verification failed. If using a self-signed certificate,
set verify_ssl: false or provide a CA certificate via ca_cert_path.

This applies to both the discovery endpoint (_validate_token) and the JWKS endpoint (_decode_token) error paths.

Which issue(s) this PR fixes:

Follow up to #6089

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc


Open with Devin

@aniketpalu aniketpalu requested a review from a team as a code owner April 8, 2026 15:11
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Collaborator

@jyejare jyejare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The Kubernetes auth path sets a status condition (AuthorizationReadyType) to indicate RBAC provisioning success/failure. The OIDC path does not. This means operators have no visibility into whether the OIDC RBAC was actually created.

  2. The existing OIDC test (featurestore_controller_oidc_auth_test.go) verifies that the Kubernetes-auth Role/RoleBinding are absent, but it does not verify that the new feast-oidc-token-review ClusterRole and per-instance ClusterRoleBinding are created with the correct rules. It also doesn't test the cleanup path (switching from OIDC to no-auth should delete the CRB).

Comment on lines 400 to 402
func (authz *FeastAuthorization) getLabels() map[string]string {
return map[string]string{
services.NameLabelKey: authz.Handler.FeatureStore.Name,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLabels() stamps the FeatureStore-specific name. But the ClusterRole feast-oidc-token-review is shared across all OIDC FeatureStore instances. The last instance to reconcile overwrites the labels with its own name. This creates misleading audit trails — the ClusterRole appears to belong to one FeatureStore when it actually serves all of them.
Recommendation: Either use instance-independent labels for the shared ClusterRole, or use an aggregated label approach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by using instance-independent labels for the shared ClusterRole

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

When authz: oidc is configured, the operator now provisions a dedicated
feast-oidc-token-review ClusterRole and per-instance ClusterRoleBinding
with tokenreviews/create permission for SA token delegation.
Changes:
- Add OIDC status condition (AuthorizationReadyType) for feature parity
  with Kubernetes auth
- Use instance-independent labels for shared ClusterRole to avoid
  misleading audit trails when multiple FeatureStores use OIDC
- Clean up Kubernetes ClusterRoleBinding when switching auth types
- Add test coverage for OIDC RBAC creation and cleanup

Signed-off-by: Aniket Paluskar <apaluska@redhat.com>
@aniketpalu aniketpalu force-pushed the oidc-rbac-ssl-logging branch from 4da984f to 15c8ec5 Compare April 27, 2026 16:06
Copy link
Copy Markdown
Collaborator

@jyejare jyejare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, small comment.

Comment on lines 413 to +425
@@ -335,6 +418,25 @@ func (authz *FeastAuthorization) getLabels() map[string]string {
}
}

func (authz *FeastAuthorization) getSharedOidcClusterRoleLabels() map[string]string {
return map[string]string{
services.ServiceTypeLabelKey: string(services.AuthzFeastType),
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ManagedByLabelKey in getLabels() — will break informer cache filtering. All RBAC resources created by the authz module (including the new OIDC resources) will be missing app.kubernetes.io/managed-by: feast-operator. Since cmd/main.go uses this label for informer cache selectors, the operator's cache won't see these resources, causing reconciliation failures or infinite create loops.

Update it with master version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants